533528
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,6 @@
import org.springframework.web.multipart.MultipartException;
 import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.multipart.MultipartResolver;
 import org.springframework.web.util.NestedServletException;
-import org.springframework.web.util.UrlPathHelper;
 import org.springframework.web.util.WebUtils;
 
 /**
@@ -246,8 +245,6 @@
public class DispatcherServlet extends FrameworkServlet {
 	/** Additional logger to use when no mapped handler is found for a request. */
 	protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
 
-	private static final UrlPathHelper urlPathHelper = new UrlPathHelper();
-
 	private static final Properties defaultStrategies;
 
 	static {
@@ -838,17 +835,15 @@
public class DispatcherServlet extends FrameworkServlet {
 	@Override
 	protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception {
 		if (logger.isDebugEnabled()) {
-			String requestUri = urlPathHelper.getRequestUri(request);
 			String resumed = WebAsyncUtils.getAsyncManager(request).hasConcurrentResult() ? " resumed" : "";
 			logger.debug("DispatcherServlet with name '" + getServletName() + "'" + resumed +
-					" processing " + request.getMethod() + " request for [" + requestUri + "]");
+					" processing " + request.getMethod() + " request for [" + getRequestUri(request) + "]");
 		}
 
 		// Keep a snapshot of the request attributes in case of an include,
 		// to be able to restore the original attributes after the include.
 		Map<String, Object> attributesSnapshot = null;
 		if (WebUtils.isIncludeRequest(request)) {
-			logger.debug("Taking snapshot of request attributes before include");
 			attributesSnapshot = new HashMap<String, Object>();
 			Enumeration<?> attrNames = request.getAttributeNames();
 			while (attrNames.hasMoreElements()) {
@@ -928,8 +923,7 @@
public class DispatcherServlet extends FrameworkServlet {
 				if (isGet || "HEAD".equals(method)) {
 					long lastModified = ha.getLastModified(request, mappedHandler.getHandler());
 					if (logger.isDebugEnabled()) {
-						String requestUri = urlPathHelper.getRequestUri(request);
-						logger.debug("Last-Modified value for [" + requestUri + "] is: " + lastModified);
+						logger.debug("Last-Modified value for [" + getRequestUri(request) + "] is: " + lastModified);
 					}
 					if (new ServletWebRequest(request, response).checkNotModified(lastModified) && isGet) {
 						return;
@@ -1114,15 +1108,15 @@
public class DispatcherServlet extends FrameworkServlet {
 	 */
 	protected void noHandlerFound(HttpServletRequest request, HttpServletResponse response) throws Exception {
 		if (pageNotFoundLogger.isWarnEnabled()) {
-			String requestUri = urlPathHelper.getRequestUri(request);
-			pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + requestUri +
+			pageNotFoundLogger.warn("No mapping found for HTTP request with URI [" + getRequestUri(request) +
 					"] in DispatcherServlet with name '" + getServletName() + "'");
 		}
-		if(throwExceptionIfNoHandlerFound) {
+		if (throwExceptionIfNoHandlerFound) {
 			ServletServerHttpRequest req = new ServletServerHttpRequest(request);
 			throw new NoHandlerFoundException(req.getMethod().name(),
 					req.getServletRequest().getRequestURI(),req.getHeaders());
-		} else {
+		}
+		else {
 			response.sendError(HttpServletResponse.SC_NOT_FOUND);
 		}
 	}
@@ -1203,9 +1197,8 @@
public class DispatcherServlet extends FrameworkServlet {
 			// We need to resolve the view name.
 			view = resolveViewName(mv.getViewName(), mv.getModelInternal(), locale, request);
 			if (view == null) {
-				throw new ServletException(
-						"Could not resolve view with name '" + mv.getViewName() + "' in servlet with name '" +
-								getServletName() + "'");
+				throw new ServletException("Could not resolve view with name '" + mv.getViewName() +
+						"' in servlet with name '" + getServletName() + "'");
 			}
 		}
 		else {
@@ -1226,8 +1219,8 @@
public class DispatcherServlet extends FrameworkServlet {
 		}
 		catch (Exception ex) {
 			if (logger.isDebugEnabled()) {
-				logger.debug("Error rendering view [" + view + "] in DispatcherServlet with name '"
-						+ getServletName() + "'", ex);
+				logger.debug("Error rendering view [" + view + "] in DispatcherServlet with name '" +
+						getServletName() + "'", ex);
 			}
 			throw ex;
 		}
@@ -1295,8 +1288,6 @@
public class DispatcherServlet extends FrameworkServlet {
 	 */
 	@SuppressWarnings("unchecked")
 	private void restoreAttributesAfterInclude(HttpServletRequest request, Map<?,?> attributesSnapshot) {
-		logger.debug("Restoring snapshot of request attributes after include");
-
 		// Need to copy into separate Collection here, to avoid side effects
 		// on the Enumeration when removing attributes.
 		Set<String> attrsToCheck = new HashSet<String>();
@@ -1316,18 +1307,20 @@
public class DispatcherServlet extends FrameworkServlet {
 		for (String attrName : attrsToCheck) {
 			Object attrValue = attributesSnapshot.get(attrName);
 			if (attrValue == null){
-				if (logger.isDebugEnabled()) {
-					logger.debug("Removing attribute [" + attrName + "] after include");
-				}
 				request.removeAttribute(attrName);
 			}
 			else if (attrValue != request.getAttribute(attrName)) {
-				if (logger.isDebugEnabled()) {
-					logger.debug("Restoring original value of attribute [" + attrName + "] after include");
-				}
 				request.setAttribute(attrName, attrValue);
 			}
 		}
 	}
 
+	private static String getRequestUri(HttpServletRequest request) {
+		String uri = (String) request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE);
+		if (uri == null) {
+			uri = request.getRequestURI();
+		}
+		return uri;
+	}
+
 }
